import request from '@/utils/request'

// 查询结算记录列表
export function listRecord(query) {
  return request({
    url: '/record/record/list',
    method: 'get',
    params: query
  })
}

// 查询结算记录详细
export function getRecord(settlementCode) {
  return request({
    url: '/record/record/' + settlementCode,
    method: 'get'
  })
}

// 新增结算记录
export function addRecord(data) {
  return request({
    url: '/record/record',
    method: 'post',
    data: data
  })
}



// 创建结算单
export function createSettlement(data) {
  return request({
    url: '/record/record',
    method: 'post',
    data: data
  });
}

// 修改结算记录
export function updateRecord(data) {
  return request({
    url: '/record/record',
    method: 'put',
    data: data
  })
}

// 删除结算记录
export function delRecord(settlementCode) {
  return request({
    url: '/record/record/' + settlementCode,
    method: 'delete'
  })
}




//根据合作方编码获取合作方详细信息
export function getRecordByPartnerCode(partnerCode) {
  return request({
    url: '/record/record/getRecordByPartnerCode',
    method: 'post',
    data: partnerCode,
  })
}

// 更新结算单状态
export function updateRecordStatus(settlementCode, status) {
  return request({
    url: '/settled/record/updateStatus',
    method: 'post',
    data: {
      settlementCode,
      status
    }
  });
}

// 支付结算单
export function payRecord(settlementCode) {
  return request({
    url: '/record/record/pay',
    method: 'post',
    data: {
      settlementCode
    }
  });
}

// 上传发票
export function uploadInvoice(settlementCode) {
  return request({
    url: '/record/record/uploadInvoice',
    method: 'post',
    data: {
      settlementCode
    }
  });
}


// 确认结算单
export function confirmSettlement(settlementRecordCode) {
  return request({
    url: '/record/record/confirm',
    method: 'post',
    params: {
      settlementRecordCode
    }
  });
}

// 完成结算单
export function completeSettlement(settlementRecordCode) {
  return request({
    url: '/settled/record/complete',
    method: 'post',
    params: {
      settlementRecordCode
    }
  });
}

// 驳回结算单
export function rejectSettlement(settlementRecordCode, rejectReason) {
  return request({
    url: '/settled/record/reject',
    method: 'post',
    params: {
      settlementRecordCode,
      rejectReason
    }
  });
}
